#include "mainwindow317.h"
#include "ui_mainwindow.h"
#include <qdebug.h>
#include "regwindows.h"
#include "mysqlqt.h"
#include <sensorsetting.h>


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

//
void MainWindow::on_SignButton_clicked()
{
    RegWindows* reg = new RegWindows();
    reg->show();
    this->close();
}

// 登录
void MainWindow::on_LogButton_clicked()
{
    QString userName = ui->NameLine->text().trimmed();
    QString userPaw = ui->PawLine->text().trimmed();
    MySqlQt sql = MySqlQt();
    QSqlDatabase db = sql.db;
    sql.ConnectSql(db);
    QString userPawSql = sql.SelectUserPaw(db,userName);
    if(userName == "" && userPaw == "")
    {
        qDebug() << "error";
    }
    if(userPaw == userPawSql)
    {
        qDebug() << "is ok";
        SensorSetting* sen = new SensorSetting();
        sen->show();
        this->close();

    }else
    {
        qDebug() << "is fate";
    }
}

